Trò chơi đua xe động vật trong UNITY Engine
114.940 lượt xem;
- ButtonStartClickListener.cs
- Prepare /
- GameScreen /
- AnimalRacing /
- Scripts /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3
4 namespace GamePlay
5 {
6 public class ButtonStartClickListener : InputAdapter
7 {
8 public GameScreen gameScreen;
9
10 public void Start()
11 {
12 gameObject.AddComponent<Actor>().addAction(new ActionRepeat(ActionRepeat.FOREVER, new ActionSequence(
13 new ActionScaleTo(0.75f, 0.75f, 0.2f, Interpolation.sine),
14 new ActionScaleTo(0.8f, 0.8f, 0.2f, Interpolation.sine)
15 )));
16 }
17
18 public override void OnTouchDown()
19 {
20 if (InputController.Name != InputNames.DIALOG) return;
21 base.OnTouchDown();
22 gameObject.GetComponent<SpriteRenderer>().color = new Color(0.5f, 0.5f, 0.5f, 1);
23 SoundManager.playButtonSound();
24 }
25 public override void OnCheckUp()
26 {
27 if (InputController.Name != InputNames.DIALOG) return;
28 base.OnCheckUp();
29 gameObject.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1);
30 }
31 public override void OnTouchUp()
32 {
33 if (InputController.Name != InputNames.DIALOG) return;
34 base.OnTouchUp();
35 if (Data.getData(Data.KEY_GUIDE) == 0)
36 {
37 gameScreen.guideGame();
38 Destroy(transform.parent.gameObject);
39 }
40 else
41 {
42 InputController.Name = "";
43 //InputController.Name = InputNames.GAMESCREEN;
44 //gameScreen.resumeGame();
45 gameScreen.showCounter();
46 Destroy(transform.parent.gameObject);
47 }
48 }
49
50 public void Update()
51 {
52 if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Backspace))
53 {
54 SoundManager.LoadBgMusic("Sounds/menu", true);
55 Application.LoadLevel("MapScreen");
56 }
57 }
58 }
59 }
2 using System.Collections;
3
4 namespace GamePlay
5 {
6 public class ButtonStartClickListener : InputAdapter
7 {
8 public GameScreen gameScreen;
9
10 public void Start()
11 {
12 gameObject.AddComponent<Actor>().addAction(new ActionRepeat(ActionRepeat.FOREVER, new ActionSequence(
13 new ActionScaleTo(0.75f, 0.75f, 0.2f, Interpolation.sine),
14 new ActionScaleTo(0.8f, 0.8f, 0.2f, Interpolation.sine)
15 )));
16 }
17
18 public override void OnTouchDown()
19 {
20 if (InputController.Name != InputNames.DIALOG) return;
21 base.OnTouchDown();
22 gameObject.GetComponent<SpriteRenderer>().color = new Color(0.5f, 0.5f, 0.5f, 1);
23 SoundManager.playButtonSound();
24 }
25 public override void OnCheckUp()
26 {
27 if (InputController.Name != InputNames.DIALOG) return;
28 base.OnCheckUp();
29 gameObject.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1);
30 }
31 public override void OnTouchUp()
32 {
33 if (InputController.Name != InputNames.DIALOG) return;
34 base.OnTouchUp();
35 if (Data.getData(Data.KEY_GUIDE) == 0)
36 {
37 gameScreen.guideGame();
38 Destroy(transform.parent.gameObject);
39 }
40 else
41 {
42 InputController.Name = "";
43 //InputController.Name = InputNames.GAMESCREEN;
44 //gameScreen.resumeGame();
45 gameScreen.showCounter();
46 Destroy(transform.parent.gameObject);
47 }
48 }
49
50 public void Update()
51 {
52 if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Backspace))
53 {
54 SoundManager.LoadBgMusic("Sounds/menu", true);
55 Application.LoadLevel("MapScreen");
56 }
57 }
58 }
59 }
InputController.Name = InputNames.GAMESCREEN;
gameScreen.resumeGame();